package com.android.jr_infraredcamera.base

import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.Window
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

/**
 * @author 战神族灬小火
 * @date 2024/11/18
 * @description
 */
abstract class BaseActivity<dataBinding : ViewDataBinding> constructor(layoutId: Int) :
    AppCompatActivity() {

    private var layoutId = 0

    protected var binding: dataBinding? = null
    companion object {
        private const val TAG = "===BaseActivity==="
    }

    init {

        this.layoutId = layoutId

    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (layoutId != 0) {
            if (binding == null) {

                binding = DataBindingUtil.setContentView(this, layoutId)

                setContentView(binding!!.root)

                binding!!.lifecycleOwner = this

            }
        }


        initData()

        initView()

        initObservable()

    }

    override fun onResume() {

        super.onResume()

    }


    abstract fun initData()


    abstract fun initView()


    abstract fun initObservable()

    /**
     *  防止连点操作
     */
    fun fastClickChecked(view: View?) {
        view?.isClickable = false
        view?.postDelayed({
            view.isClickable = true
        }, 1000)
    }

    override fun onDestroy() {
        super.onDestroy()
        binding?.unbind()
        binding = null
    }
}